{extend name="index_layout"/}
{block name="main"}

<div class="layui-card">
    <div class="layui-card-header">用户问题反馈</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('question.questionfback/add')}"
                   data-auth-edit="{:$auth->check('question.questionfback/edit')}"
                   data-auth-delete="{:$auth->check('question.questionfback/del')}"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/html" id="picTpl">
    <img style="max-width:100px; max-height:60px;" src="{{d.img_url}}" data-image="{{d.name}}">
</script>

<script type="text/html" id="barTool">

    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="查看详情"
       data-full="true">查看详情</a>
    {{# if(d.is_reply==0){ }}
    <a class="layui-btn layui-btn-xs  layui-btn-normal" data-open='{:url("reply")}?id={{ d.id }}' data-title="问题回复"
       data-full="true">问题回复</a>
    {{# } }}

    {{# if(d.is_reply==1){ }}
    <a class="layui-btn layui-btn-xs  layui-btn-primary" data-open='{:url("reply")}?id={{ d.id }}' data-title="查看回复"
       data-full="true">查看回复</a>
    {{# } }}


</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="启动|关闭" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/javascript">

    function arrayToObject(arr) {
        let obj = {};
        for (let i = 0; i < arr.length; i++) {
            obj[i] = arr[i];
        }
        return obj;
    }
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
        };
        var arr = {:json_encode($qc)};
        var qc= {1: '启动', 0: '关闭'};

        table.render({
            init: init,
            toolbar: ['refresh'],
            url: '{:url("index")}',
            cols: [
                [
                    //名称 水票背景图 所属商品分类 所属商品
                    {field: 'id', Width: 80,align: "center", title: 'ID',search:false},
                    {field: 'nickname', Width: 100,   align: "center", title: '反馈用户'},
                    {field: 'mobile', Width: 100,   align: "center", title: '手机号'},
                    {field: 'content', Width: 100,   align: "center", title: '反馈问题',search:false},
                    {field: 'create_time', Width: 100,   align: "center", title: '反馈时间', search: 'range'},
                    {field: 'is_reply', Width: 100,   align: "center", title: '是否回复', templet: function (d) {
                            if (d.is_reply == 0) {
                                return '<span style="color: orangered">未回复</span>';
                            } else if (d.is_reply == 1) {
                                return '<span style="color:  #00B7EE ">已回复</span>';
                            } else{
                                return '<span>未知</span>';
                            }
                        },selectList: {0:'未回复',1:'已回复'}},
                    {fixed: 'right', Width: 120,align: "center", title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });

        yznTable.bindevent();
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);
    });
</script>
{/block}